The following programs are written in the software Matlab version 2014a (for Windows) for "The explicit formula for the Hodrick-Prescott filter in finite sample" by Adriana Cornea-Madeira. Email address: adriana.cornea-madeira@york.ac.uk 

1. HPTheorem1vsHPinvmatrix.m compares the results from Theorem 1 with the HP filter based on the direct inversion of the matrix in (2)

2. HPweightsvsHPinvmatrix.m compares the results from Corollaries 6 and 7 with the HP filter based on the direct inversion of the matrix in (2)

3. HPweightsfast.m gives an alternative Matlab code to the code from HPweightsvsHPinvmatrix.m corresponding to Corollaries 6 and 7 which works faster than 
HPweightsvsHPinvmatrix.m for large sample size (denoted n). The code is for n an even number.

4. HPweightsFig1.m, HPinvmatrixFig1.m and SKFFig1.m correspond to the HP filter based on the weights from Corollaries 6 and 7, 
the HP filter based on the direct inversion of the matrix in (2) and the Kalman filter plus smoothing, used for Figure 1 in the Supplemental Appendix; see the Supplemental Appendix for further details. The results from Figure 1 from the Supplemental Appendix were run in Matlab version 2014a on an Intel(R) PC
with Core(TM)i5-4570 CPU 3.20 GHz, 8GB RAM, Windows 64-bit operating system. The output of HPweightsFig1.m, HPinvmatrixFig1.m and SKFFig1.m (for 1 sample, 20 samples and 50 samples) is stored in the .dat files: time1varHPnew.dat, time1varHPold.dat, time1varKF.dat, time20varKF.dat, time50varHPnew.dat, time50varHPold.dat, time50varKF.dat which are used to provide Figure 1.




